<template>
    <div> 
         <h1>登录页面</h1>
    </div>
     <table class="table">
        <thead> 
             <tr>
                <td>用户名</td>
                 <td>
                    <input type="text" v-model="data.name">
                 </td>
             </tr>

                <tr>
                <td>密码</td>
                 <td>
                     <input type="password" v-model="data.pwd">
                 </td>
             </tr>

                <tr>
                <td></td>
                 <td>
                   <input type="button" value="登录" @click="loing">
                 </td>
             </tr>
        </thead>
     </table>
</template>

<script setup lang="ts">
  import axios from 'axios';
  import{ref,onMounted} from 'vue';
 import {useRouter} from 'vue-router';
 import{usesreStore} from '../../stores/usermager'
 const user=usesreStore();

 const router=useRouter();

 const data=ref({
     name:"",
     pwd:"",

 })

  const loing=()=>{
     axios.get("https://localhost:7295/api/UserMager/Loing",{params:data.value}).then(res=>{
          if(res.data.userMagerId==-1){
            alert("用户名不存在")
             return;
          }else if(res.data.userMagerId==-2){
              alert("密码错误")
             return;
          }else{
                 alert("登录成功")
                user.userdate.userMagerName=res.data.name;
                user.userdate.userMagerPwd=res.data.pwd;
                 router.push("/sho");
                 
          } 
     })
  }
</script>

<style scoped>

</style>
